﻿using System.Windows.Controls;
using System.Windows.Media;

namespace AgLux
{
    /// <summary>
    /// //
    /// </summary>

    public class Audio : Media
    {
        /// <summary>
        /// //
        /// </summary>

        /// <param name="source">
        /// //
        /// </param>

        /// <param name="caption">
        /// //
        /// </param>

        public Audio(string source, string transcript, string caption)
            : base(source,transcript)
        {
            _control.Width = 70;
            _control.Height = 40;
            _control.SetValue(Canvas.LeftProperty, _volume.Width + 10);
            _control.Background = new SolidColorBrush(Color.FromRgb(33, 131, 197));
            _control.Opacity = 1;

            _play.SetValue(Canvas.LeftProperty, 10);
            _play.SetValue(Canvas.TopProperty, 10);

            _pause.SetValue(Canvas.LeftProperty, 10);
            _pause.SetValue(Canvas.TopProperty, 10);

            _stop.SetValue(Canvas.LeftProperty, 40);
            _stop.SetValue(Canvas.TopProperty, 10);

            _caption.Text = caption;

            _volume.Width += _control.Width + 10;
        }

        /// <summary>
        /// //
        /// </summary>

        /// <param name="canvasWidth">
        /// //
        /// </param>

        public override void FitCanvas(double canvasWidth)
        {
            Width = canvasWidth;
            ScreenWidth = canvasWidth;

            ScreenHeight = -5;
            SetCaption();
            _control.SetValue(Canvas.TopProperty, _caption.Height + _volume.Height / 2 - _control.Height / 2);

            ScreenHeight = -10;
            SetVolume();
            SetScrub(Width - _volume.Width - 10);

            Height = _caption.Height + _volume.Height + 10;
        }
    }
}
